 <%--
 *  File:  uploadconfigmain.jsp
 *  Desc:	
 *
 *  @Author: jeanhuang
 *  Date:    2013/15/31
 *
 *  Copyright (C) 2000 - 2008 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
  //init param
  String strModuleName = "DMS";
  String privilegeCode = "IMG0303";
  String contextPath = request.getContextPath();
  String strFlag=request.getParameter("displayflag");
  String isNew = request.getParameter("isNew");
	String isNeed = "need";
	  if(isNew == null){
		  isNeed = "td-text";
	  }
%>
<%@ include file="/inc/CommonHeader.inc" %>

<html>
<head>
<title>uploadconfigmain</title>
<PageFlow:CheckPageFlow pageName="p_uploadconfigmain"/>
<%@ include file="/inc/CatchError.inc" %>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/Calendar.js"></script>
<%

	HashMap uploadconfighash = (HashMap)pageContext.getAttribute("uploadconfighash");
	String checked = "";
	String disabled = "";
	if(uploadconfighash == null){
		uploadconfighash = new HashMap();
	}
	
	if(strFlag.equals("view")){
		disabled = "disabled";
		
	}
	Integer uploadconfigid = (Integer)uploadconfighash.get("uploadconfigid");
	boolean hasId = !(uploadconfigid==null);
%>
<%--  edit page related functions   --%>
<%if(!isView){%><script language="JavaScript">

function page_save()
{
	if(!checkForm(cform))   return;
	if (document.cform.tablename){
		var tablename = document.cform.tablename.value;
		if(tablename==null||tablename==""||tablename==-1){
			alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_VtableName",false))%>");
			return;
		}
	}
	if (document.cform.pkcolumnname){
		var pkcolumnname = document.cform.pkcolumnname.value;
		if(pkcolumnname==null||pkcolumnname==""||pkcolumnname==-1){
			alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Pkname",false))%>");
			return;
		}
	}

	if (document.cform.tactics){
		var tactics = document.cform.tactics.value;
		if(tactics==null||tactics==""||tactics==-1){
			alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Tactics",false))%>");
			return;
		}
	}

	if (document.cform.status){
		var status = document.cform.status.value;
		if(status==null||status==""||status==-1){
			alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_status",false))%>");
			return;
		}
	}
	
	cform.actionname.value = "save";
	cform.target = "_parent";
	isRunning = true;
	cform.submit();
}
</script><%}%>

<%--  other functions   --%>
<script language="JavaScript">
function hasHeader(){
	var rowcountspan = document.getElementById("rowcount");
	var hasheader = document.cform.hasheader.value;
	if(hasheader == 1){
		rowcountspan.style.display='inline';
		document.cform.headerlinecount.command='positive';
	}else{
		document.cform.headerlinecount.value='';
		rowcountspan.style.display='none';
		document.cform.headerlinecount.command='';
	}
}
function page_back(){
	parent.location.href="uploadConfigSummary.jsp?<%=OvalTools.randomURL()%>";
}
function getTableName(){
	document.cform.tablename.value = "";
	if(document.cform.filedatatype.value == " ")
	  return;
	var  datahandler = new  DataHandler() ;
	datahandler.add_params("processtype" , document.cform.filedatatype.value,"Integer");
	datahandler.getResult("tablename","document.cform.tablename"); 
	datahandler.add_job("j_gettablename") ;
	datahandler.runDataHandler ();
}

function checkchange(){
	var standerflag = document.cform.standerflag;
	if(!parent.up.document.getElementById('A03')){
		window.location.reload();
	}
	if(standerflag.checked){
		parent.up.document.getElementById('A03').style.display = 'none';
	}else {
		parent.up.document.getElementById('A03').style.display = 'block';
	}
}

function setReadonly(){
	//var displayflag = '<%=strFlag %>';
	if (document.cform.uploadconfigid){
		//document.cform.columnmappingrulename.disabled = "disabled";
		document.cform.filedatatype.disabled = "disabled";
	}else {
		document.cform.startline.value = "2";
	}
}

function showOrHide(){
	var tactics = document.cform.tactics.value;
	if(tactics==3){
		document.cform.tacticsproname.style.display="block";
		document.cform.tacticsproname.command="notnull";
	}else{
		document.cform.tacticsproname.style.display="none";
		document.cform.tacticsproname.command="";
	}
	
}

function changesetvalue(obj){
	var textobj=obj.options[obj.selectedIndex].text;
	if(obj.value!=""&&obj.value!=null&&obj.value!=-1){
		document.cform.tablename.value=textobj;
		setkeyvalue(obj.value,textobj);
	}else{
		document.cform.tablename.value="";
	}
}

function setkeyvalue(tableid,tablename){
	  document.cform.pkcolumnname.length=1;
	  var  datahandler = new  DataHandler() ;
	  datahandler.add_params("tablename" ,tablename,"String");
	  datahandler.add_params("ispk" ,"Y","String");
	  datahandler.add_params("languagecode" ,"<%=strLanguageCode %>","String");
	  datahandler.add_job("j_gettableinfo");
	   
	  datahandler.getResultFromVector("columndatas","columnname" ,"columnname","document.cform.pkcolumnname");
	  datahandler.runDataHandler();
}

</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="overflow: auto;">
<iframe name="reloadHandler" style="display:none" ></iframe>
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_uploadconfigmain">
    <input type="hidden" name="actionname">
    <input type="hidden" name="flag">
    <custom:hidden name="uploadconfighash" property="uploadconfigid" />

<table border=0 cellpadding=0 cellspacing=0 width="100%">
  <tr>
    <td valign=top>
      <table border=0 cellpadding=1 cellspacing=0 width="100%">
        <tr>
          <td bgcolor=#000000 style="PADDING-BOTTOM: 1px; PADDING-LEFT: 1px; PADDING-RIGHT: 1px; PADDING-TOP: 0px">
            <table bgcolor=#000000 border=0 cellpadding=0 cellspacing=0 width="100%">
              <tr>
                <td  bgcolor=#ffffff style="PADDING-BOTTOM: 3px; PADDING-LEFT: 3px; PADDING-RIGHT: 3px; PADDING-TOP: 3px" valign="top">
                  <div id=div2 style="HEIGHT: 415px; OVERFLOW: auto;">
                    <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">

<%--    top function buttons    --%>
<% if(!isView){%>
                      <tr>
                        <td colspan="4" class="td_right" height="18">
                          <a onclick="page_save()"><custom:button type="2" label="L_Save" imgsrc="save_btn.gif" border="0" /></a>
                        </td>
                      </tr>
<%}%>

                      <tr>
                        
                        <td width="150" class="<%=needClass%>" ><%=label.getLabelName("L_ConfigCode")+label.getLabelName("L_Colon")%></td>
                        <td width="300"> 
                     	<%if(uploadconfigid == null){ %>
                        <custom:text style="border:1px #7F9DB9 solid;" name="uploadconfighash" property="code" size="20" command="notnull"  label="L_ConfigCode" />
                        <%}else{ %>
                        <custom:write property="code" name="uploadconfighash" nbsp="true"/>
                        <%} %>
                        </td>
                        <td width="150" class="<%=needClass %>" id="autocode"> <%=label.getLabelName("L_ConfigName")+label.getLabelName("L_Colon")%></td>
                        <td> 
                       
                        <custom:text style="border:1px #7F9DB9 solid;" name="uploadconfighash" property="name" size="20" command="notnull"  label="L_ConfigName" />
                       
                        </td>
                      </tr>
                      <tr> 
				          <td class="<%=needClass %>" width="150">&nbsp;<%= label.getLabelName("L_VtableName") %><%= label.getLabelName("L_Colon") %></td>
				          <td>
				          	<%if (hasId) {%>
				          	<custom:write name="uploadconfighash" property="tablename"/>
				          	<%} else {%>
				          	<custom:select optionsName="alltables" name="uploadconfighash" property="tablename" optionInnerTextKey="tablename" optionValueKey="tablename" defaultValue="---------" onchange="changesetvalue(this)"/>
				          	<%} %>
				          </td>
				          <td  class="<%=needClass%>" ><%=label.getLabelName("L_Pkname")+label.getLabelName("L_Colon")%></td>
				          <%if (hasId) {%>
				          	<TD><custom:write name="uploadconfighash" property="pkcolumnname"/></TD>
				          	<%} else {%>
				          	<td><custom:select name="uploadconfighash" property="pkcolumnname" optionsName="columndatas" optionValueKey="columnname" optionInnerTextKey="columnname" defaultValue="---------" /></td>
				          	<%} %>
				          
				        </tr>
                      <tr>
                        <td class="<%=needClass%>">&nbsp;<%=label.getLabelName("L_Tactics")+label.getLabelName("L_Colon")%></td>
                        <td >
                        	 <custom:selectdic disabled="<%=isView %>" defaultValueCost=" " onchange="showOrHide()"  name="uploadconfighash" property="tactics" dictType="uploadtactics" />
                        	 <custom:text style="border:1px #7F9DB9 solid;" name="uploadconfighash" property="tacticsproname" size="20" label="L_TacticsProcess"/>
                        </td>
                        
                        <td  class="<%=needClass%>" ><%=label.getLabelName("L_status")+label.getLabelName("L_Colon")%></td>
                        <td> 
                        	<%if (hasId) {%>
				          	<custom:write name="uploadconfighash" property="status" dictType="Status"/>
				          	<%} else {%>
				          	<custom:selectdic dictType="Status" property="status" name="uploadconfighash" valueCriteria="10"/>
				          	<%} %>
                        
                        </td>
                      </tr>
                      
                      <tr>
                        <td class="<%=needClass%>" width="150"><%= label.getLabelName("L_BeginLine") %><%= label.getLabelName("L_Colon") %></td>
				        <td> <custom:text style="border:1px #7F9DB9 solid;" name="uploadconfighash" property="startrow" size="20" command="notnull"  label="L_BeginLine"/></td>
           				<td class="<%=needClass%>"><%= label.getLabelName("L_SequenceSetting") %><%= label.getLabelName("L_Colon") %></td>
				        <td> <custom:text name="uploadconfighash" property="tableseq" size="20" command="notnull"  label="L_SequenceSetting"/></td>
                      </tr>

                    </table>
                  </div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
         <tr><td class="summary_top"></td></tr>
         <tr>
           <td class="td_center">
          
             <a onclick="page_back();"><custom:button type="1" label="L_Back" imgsrc="new.gif" border="0" style="width:60"/></a>
          
           </td>
         </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</body>
<script>
	
	//checkchange();
	<% if(!isView){%>
		showOrHide();
		//setReadonly();
		//getTableName();
	<%} %>
</script>
</html>